<?php

namespace app\admin\validate\merchant;



use think\Validate;

class Merchant extends Validate
{


    protected $rule =   [

//        'name'  => ['require', 'unique'=>'merchant','length'=>'2,12'],
//        'password'=>['require','confirm','length'=>'6,16'],
        'appid'=>['require'],
        'secret'=>['require'],
        'key'=>['require'],
//        'status'=>['require'],
    ];

    protected $message  =   [

//        'name.require'      => ['code' => 4012, 'msg' => '会员名称不能为空'],
//        'name.unique'      => ['code' => 4013, 'msg' => '会员名称已经存在'],
//        'name.length'      => ['code' => 4013, 'msg' => '会员名称长度3到12位'],
//        'password.confirm'   => ['code' => 4015, 'msg' => '二次密码不一致'],
//        'password.require'   => ['code' => 4015, 'msg' => '密码不能为空'],
        'status.require'   => ['code' => 4015, 'msg' => '状态必须'],
        'password.length'    => ['code' => 4016, 'msg' => '密码至少6-16位'],
        'appid.require'      => ['code' => 4019, 'msg' => 'appid 必填'],
        'secret.require'      => ['code' => 4019, 'msg' => 'secret 必填'],
        'key.require'      => ['code' => 4019, 'msg' => 'key 必填'],

    ];
    // edit 验证场景定义
    public function sceneModify()
    {
        return $this->remove('password',true);
    }

    public function sceneMemberModify()
    {
        return $this->remove('password',true)->remove('status',true);
    }

    // edit 验证场景定义
    public function sceneLogin()
    {
        return $this->only(['username','password'])->remove(['username'=>'unique','password'=>'confirm']);
    }

    public function sceneModifyPassword()
    {
        return $this->only(['password']);
    }

}